Add different CardSets for rendering of preferences.
[lhc/web/wiklou.git] / includes / SkinPHPTal.php
1 <?php
2 # Generic PHPTal (http://phptal.sourceforge.net/) skin
3 # Based on Brion's smarty skin
4 # Copyright (C) Gabriel Wicke -- http://www.aulinx.de/
5 #
6 # Todo: Needs some serious refactoring into functions that correspond
7 # to the computations individual esi snippets need. Most importantly no body
8 # parsing for most of those of course.
9 #
10 # Set this in LocalSettings to enable phptal:
11 # set_include_path(get_include_path() . ":" . $IP.'/PHPTAL-NP-0.7.0/libs');
12 # $wgUsePHPTal = true;
13 #
14 # This program is free software; you can redistribute it and/or modify
15 # it under the terms of the GNU General Public License as published by
16 # the Free Software Foundation; either version 2 of the License, or
17 # (at your option) any later version.
18 #
19 # This program is distributed in the hope that it will be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 # GNU General Public License for more details.
23 #
24 # You should have received a copy of the GNU General Public License along
25 # with this program; if not, write to the Free Software Foundation, Inc.,
26 # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27 # http://www.gnu.org/copyleft/gpl.html
28
29 require_once "GlobalFunctions.php";
30 require_once $IP."/PHPTAL-NP-0.7.0/libs/PHPTAL.php";
31
32 require_once "TabbedCardSet.php";
33
34 class MediaWiki_I18N extends PHPTAL_I18N
35 {
36 var $_context = array();
37
38 function set($varName, $value) {
39 $this->_context[$varName] = $value;
40 }
41
42 function translate($value) {
43 $value = wfMsg( $value );
44 // interpolate variables
45 while (preg_match('/\$([0-9]*?)/sm', $value, $m)) {
46 list($src, $var) = $m;
47 $varValue = @$this->_context[$var];
48 $value = str_replace($src, $varValue, $value);
49 }
50 return $value;
51 }
52 }
53
54 class SkinPHPTal extends Skin {
55 var $template;
56
57 function initPage( &$out ) {
58 parent::initPage( $out );
59 $this->skinname = "davinci";
60 $this->template = "xhtml_slim";
61 }
62
63 function outputPage( &$out ) {
64 global $wgTitle, $wgArticle, $wgUser, $wgLang, $wgOut;
65 global $wgScript, $wgStylePath, $wgLanguageCode, $wgUseNewInterlanguage;
66 global $wgMimeType, $wgOutputEncoding, $wgUseDatabaseMessages, $wgRequest;
67 global $wgDisableCounters, $wgLogo, $action, $wgFeedClasses;
68
69 extract( $wgRequest->getValues( 'oldid', 'diff' ) );
70
71 $this->initPage( $out );
72 $tpl = new PHPTAL($this->template . '.pt', 'templates');
73
74 #if ( $wgUseDatabaseMessages ) { // uncomment this to fall back to GetText
75 $tpl->setTranslator(new MediaWiki_I18N());
76 #}
77
78 $this->thispage = $wgTitle->getPrefixedDbKey();
79 $this->thisurl = $wgTitle->getPrefixedURL();
80 $this->loggedin = $wgUser->getID() != 0;
81 $this->iscontent = ($wgTitle->getNamespace() != Namespace::getSpecial() );
82 $this->iseditable = ($this->iscontent and !($action == 'edit' or $action == 'submit'));
83 $this->username = $wgUser->getName();
84 $this->userpage = $wgLang->getNsText( Namespace::getUser() ) . ":" . $wgUser->getName();
85 $this->userpageUrlDetails = $this->makeUrlDetails($this->userpage);
86
87 $this->usercss = $this->userjs = $this->userjsprev = false;
88 if( $this->loggedin ) { $this->setupUserCssJs(); }
89
90 $this->titletxt = $wgTitle->getPrefixedText();
91
92 $tpl->set( "title", $wgOut->getPageTitle() );
93 $tpl->set( "pagetitle", $wgOut->getHTMLTitle() );
94
95 $tpl->setRef( "thispage", &$this->thispage );
96 $subpagestr = $this->subPageSubtitle();
97 $tpl->set(
98 "subtitle", !empty($subpagestr)?
99 '<span class="subpages">'.$subpagestr.'</span>'.$out->getSubtitle():
100 $out->getSubtitle()
101 );
102 $tpl->set( 'catlinks', $this->getCategories());
103 if( $wgOut->isSyndicated() ) {
104 $feeds = array();
105 foreach( $wgFeedClasses as $format => $class ) {
106 $feeds[$format] = array(
107 'text' => $format,
108 'href' => $wgRequest->appendQuery( "feed=$format" ),
109 'ttip' => wfMsg('tooltip-'.$format)
110 );
111 }
112 $tpl->setRef( 'feeds', &$feeds );
113 }
114 $tpl->setRef( 'mimetype', &$wgMimeType );
115 $tpl->setRef( 'charset', &$wgOutputEncoding );
116 $tpl->set( 'headlinks', $out->getHeadLinks() );
117 $tpl->set( 'customscript', $out->getScript() );
118 $tpl->setRef( 'skinname', &$this->skinname );
119 $tpl->setRef( "loggedin", &$this->loggedin );
120 /* XXX currently unused, might get useful later
121 $tpl->set( "editable", ($wgTitle->getNamespace() != NS_SPECIAL ) );
122 $tpl->set( "exists", $wgTitle->getArticleID() != 0 );
123 $tpl->set( "watch", $wgTitle->userIsWatching() ? "unwatch" : "watch" );
124 $tpl->set( "protect", count($wgTitle->getRestrictions()) ? "unprotect" : "protect" );
125 $tpl->set( "helppage", wfMsg('helppage'));
126 $tpl->set( "sysop", $wgUser->isSysop() );
127 */
128 $tpl->set( "searchaction", $this->escapeSearchLink() );
129 $tpl->setRef( "stylepath", &$wgStylePath );
130 $tpl->setRef( "logopath", &$wgLogo );
131 $tpl->setRef( "lang", &$wgLanguageCode );
132 $tpl->set( "dir", $wgLang->isRTL() ? "rtl" : "ltr" );
133 $tpl->set( "rtl", $wgLang->isRTL() );
134 $tpl->set( "langname", $wgLang->getLanguageName( $wgLanguageCode ) );
135 $tpl->setRef( "username", &$this->username );
136 $tpl->setRef( "userpage", &$this->userpage);
137 $tpl->setRef( "userpageurl", &$this->userpageUrlDetails['href']);
138 $tpl->setRef( "usercss", &$this->usercss);
139 $tpl->setRef( "userjs", &$this->userjs);
140 $tpl->setRef( "userjsprev", &$this->userjsprev);
141 if( $wgUser->getNewtalk() ) {
142 $usertitle = Title::newFromText( $this->userpage );
143 $usertalktitle = $usertitle->getTalkPage();
144 if($usertalktitle->getPrefixedDbKey() != $this->thispage){
145
146 $ntl = wfMsg( "newmessages",
147 $this->makeKnownLink(
148 $wgLang->getNsText( Namespace::getTalk( Namespace::getUser() ) )
149 . ":" . $this->username,
150 wfMsg("newmessageslink") )
151 );
152 }
153 } else {
154 $ntl = "";
155 }
156
157 $tpl->setRef( "newtalk", &$ntl );
158 $tpl->setRef( "skin", &$this);
159 $tpl->set( "logo", $this->logoText() );
160 if ( $wgOut->isArticle() and (!isset( $oldid ) or isset( $diff )) and 0 != $wgArticle->getID() ) {
161 if ( !$wgDisableCounters ) {
162 $viewcount = $wgLang->formatNum( $wgArticle->getCount() );
163 if ( $viewcount ) {
164 $tpl->set('viewcount', wfMsg( "viewcount", $viewcount ));
165 }
166 }
167 $tpl->set('lastmod', $this->lastModified());
168 $tpl->set('copyright',$this->getCopyright());
169 }
170 $tpl->set( "copyrightico", $this->getCopyrightIcon() );
171 $tpl->set( "poweredbyico", $this->getPoweredBy() );
172 $tpl->set( "disclaimer", $this->disclaimerLink() );
173 $tpl->set( "about", $this->aboutLink() );
174
175 $tpl->setRef( "debug", &$out->mDebugtext );
176 $tpl->set( "reporttime", $out->reportTime() );
177
178 $tpl->setRef( "bodytext", &$out->mBodytext );
179
180 $language_urls = array();
181 foreach( $wgOut->getLanguageLinks() as $l ) {
182 $nt = Title::newFromText( $l );
183 $language_urls[] = array('href' => $nt->getFullURL(),
184 'text' => ($wgLang->getLanguageName( $nt->getInterwiki()) != ''?$wgLang->getLanguageName( $nt->getInterwiki()) : $l),
185 'class' => $wgLang->isRTL() ? 'rtl' : 'ltr');
186 }
187 if(count($language_urls)) {
188 $tpl->setRef( 'language_urls', &$language_urls);
189 } else {
190 $tpl->set('language_urls', false);
191 }
192 $tpl->set('personal_urls', $this->buildPersonalUrls());
193 $content_actions = $this->buildContentActionUrls();
194 $tpl->setRef('content_actions', &$content_actions);
195 // XXX: attach this from javascript, same with section editing
196 if($this->iseditable && $wgUser->getOption("editondblclick") )
197 {
198 $tpl->set('body-ondblclick', 'document.location = "' .$content_actions['edit']['href'] .'";');
199 } else {
200 $tpl->set('body-ondblclick', false);
201 }
202 $tpl->set( 'body-onload',$wgOut->getOnloadHandler() );
203 $tpl->set( "nav_urls", $this->buildNavUrls() );
204
205 // execute template
206 $res = $tpl->execute();
207 // result may be an error
208 if (PEAR::isError($res)) {
209 echo $res->toString(), "\n";
210 } else {
211 echo $res;
212 }
213
214 }
215
216 # build array of urls for personal toolbar
217 function buildPersonalUrls() {
218 /* set up the default links for the personal toolbar */
219 global $wgShowIPinHeader;
220 $personal_urls = array();
221 if ($this->loggedin) {
222 $personal_urls['userpage'] = array(
223 'text' => $this->username,
224 'href' => &$this->userpageUrlDetails['href'],
225 'class' => $this->userpageUrlDetails['exists']?false:'new',
226 'ttip' => wfMsg('tooltip-userpage'),
227 'akey' => wfMsg('accesskey-userpage')
228 );
229 $usertalkUrlDetails = $this->makeTalkUrlDetails($this->userpage);
230 $personal_urls['mytalk'] = array(
231 'text' => wfMsg('mytalk'),
232 'href' => &$usertalkUrlDetails['href'],
233 'class' => $usertalkUrlDetails['exists']?false:'new',
234 'ttip' => wfMsg('tooltip-mytalk'),
235 'akey' => wfMsg('accesskey-mytalk')
236 );
237 $personal_urls['preferences'] = array(
238 'text' => wfMsg('preferences'),
239 'href' => $this->makeSpecialUrl('Preferences'),
240 'ttip' => wfMsg('tooltip-preferences'),
241 'akey' => wfMsg('accesskey-preferences')
242 );
243 $personal_urls['watchlist'] = array(
244 'text' => wfMsg('watchlist'),
245 'href' => $this->makeSpecialUrl('Watchlist'),
246 'ttip' => wfMsg('tooltip-watchlist'),
247 'akey' => wfMsg('accesskey-watchlist')
248 );
249 $personal_urls['mycontris'] = array(
250 'text' => wfMsg('mycontris'),
251 'href' => $this->makeSpecialUrl('Contributions','target=' . $this->username),
252 'ttip' => wfMsg('tooltip-mycontris'),
253 'akey' => wfMsg('accesskey-mycontris')
254 );
255 $personal_urls['logout'] = array(
256 'text' => wfMsg('userlogout'),
257 'href' => $this->makeSpecialUrl('Userlogout','returnto=' . $this->thisurl),
258 'ttip' => wfMsg('tooltip-logout'),
259 'akey' => wfMsg('accesskey-logout')
260 );
261 } else {
262 if( $wgShowIPinHeader && isset( $_COOKIE[ini_get("session.name")] ) ) {
263 $personal_urls['anonuserpage'] = array(
264 'text' => $this->username,
265 'href' => &$this->userpageUrlDetails['href'],
266 'class' => $this->userpageUrlDetails['exists']?false:'new',
267 'ttip' => wfMsg('tooltip-anonuserpage'),
268 'akey' => wfMsg('accesskey-anonuserpage')
269 );
270 $usertalkUrlDetails = $this->makeTalkUrlDetails($this->userpage);
271 $personal_urls['anontalk'] = array(
272 'text' => wfMsg('anontalk'),
273 'href' => &$usertalkUrlDetails['href'],
274 'class' => $usertalkUrlDetails['exists']?false:'new',
275 'ttip' => wfMsg('tooltip-anontalk'),
276 'akey' => wfMsg('accesskey-anontalk')
277 );
278 $personal_urls['anonlogin'] = array(
279 'text' => wfMsg('userlogin'),
280 'href' => $this->makeSpecialUrl('Userlogin', 'returnto='.$this->thisurl),
281 'ttip' => wfMsg('tooltip-login'),
282 'akey' => wfMsg('accesskey-login')
283 );
284 } else {
285
286 $personal_urls['login'] = array(
287 'text' => wfMsg('userlogin'),
288 'href' => $this->makeSpecialUrl('Userlogin', 'returnto='.$this->thisurl),
289 'ttip' => wfMsg('tooltip-login'),
290 'akey' => wfMsg('accesskey-login')
291 );
292 }
293 }
294
295 return $personal_urls;
296 }
297
298 # an array of edit links by default used for the tabs
299 function buildContentActionUrls () {
300 global $wgTitle, $wgUser, $wgRequest;
301 $action = $wgRequest->getText( 'action' );
302 $section = $wgRequest->getText( 'section' );
303 $oldid = $wgRequest->getVal( 'oldid' );
304 $diff = $wgRequest->getVal( 'diff' );
305 $content_actions = array();
306
307 if( $this->iscontent ) {
308
309 $content_actions['article'] = array('class' => (!Namespace::isTalk( $wgTitle->getNamespace())) ? 'selected' : false,
310 'text' => $this->getNameSpaceWord(),
311 'href' => $this->makeArticleUrl($this->thispage),
312 'ttip' => wfMsg('tooltip-article'),
313 'akey' => wfMsg('accesskey-article'));
314
315 /* set up the classes for the talk link */
316 $talk_class = (Namespace::isTalk( $wgTitle->getNamespace()) ? 'selected' : false);
317 $talktitle = Title::newFromText( $this->titletxt );
318 $talktitle = $talktitle->getTalkPage();
319 $this->checkTitle(&$talktitle, &$this->titletxt);
320 if($talktitle->getArticleId() != 0) {
321 $content_actions['talk'] = array(
322 'class' => $talk_class,
323 'text' => wfMsg('talk'),
324 'href' => $this->makeTalkUrl($this->titletxt),
325 'ttip' => wfMsg('tooltip-talk'),
326 'akey' => wfMsg('accesskey-talk')
327 );
328 } else {
329 $content_actions['talk'] = array(
330 'class' => $talk_class?$talk_class.' new':'new',
331 'text' => wfMsg('talk'),
332 'href' => $this->makeTalkUrl($this->titletxt,'action=edit'),
333 'ttip' => wfMsg('tooltip-talk'),
334 'akey' => wfMsg('accesskey-talk')
335 );
336 }
337
338 if ( $wgTitle->userCanEdit() ) {
339 $oid = ( $oldid && ! isset( $diff ) ) ? "&oldid={$oldid}" : false;
340 $istalk = ( Namespace::isTalk( $wgTitle->getNamespace()) );
341 $istalkclass = $istalk?' istalk':'';
342 $content_actions['edit'] = array(
343 'class' => ((($action == 'edit' or $action == 'submit') and $section != 'new') ? 'selected' : '').$istalkclass,
344 'text' => wfMsg('edit'),
345 'href' => $this->makeUrl($this->thispage, 'action=edit'.$oid),
346 'ttip' => wfMsg('tooltip-edit'),
347 'akey' => wfMsg('accesskey-edit')
348 );
349 if ( $istalk ) {
350 $content_actions['addsection'] = array(
351 'class' => $section == 'new'?'selected':false,
352 'text' => wfMsg('addsection'),
353 'href' => $this->makeUrl($this->thispage, 'action=edit&section=new'),
354 'ttip' => wfMsg('tooltip-addsection'),
355 'akey' => wfMsg('accesskey-addsection')
356 );
357 }
358 } else {
359 $oid = ( $oldid && ! isset( $diff ) ) ? "&oldid={$oldid}" : '';
360 $content_actions['edit'] = array('class' => ($action == 'edit') ? 'selected' : false,
361 'text' => wfMsg('viewsource'),
362 'href' => $this->makeUrl($this->thispage, 'action=edit'.$oid),
363 'ttip' => wfMsg('tooltip-viewsource'),
364 'akey' => wfMsg('accesskey-viewsource'));
365 }
366
367 if ( $wgTitle->getArticleId() ) {
368
369 $content_actions['history'] = array('class' => ($action == 'history') ? 'selected' : false,
370 'text' => wfMsg('history_short'),
371 'href' => $this->makeUrl($this->thispage, 'action=history'),
372 'ttip' => wfMsg('tooltip-history'),
373 'akey' => wfMsg('accesskey-history'));
374
375 # XXX: is there a rollback action anywhere or is it planned?
376 # Don't recall where i got this from...
377 /*if( $wgUser->getNewtalk() ) {
378 $content_actions['rollback'] = array('class' => ($action == 'rollback') ? 'selected' : false,
379 'text' => wfMsg('rollback_short'),
380 'href' => $this->makeUrl($this->thispage, 'action=rollback'),
381 'ttip' => wfMsg('tooltip-rollback'),
382 'akey' => wfMsg('accesskey-rollback'));
383 }*/
384
385 if($wgUser->isSysop()){
386 if(!$wgTitle->isProtected()){
387 $content_actions['protect'] = array(
388 'class' => ($action == 'protect') ? 'selected' : false,
389 'text' => wfMsg('protect'),
390 'href' => $this->makeUrl($this->thispage, 'action=protect'),
391 'ttip' => wfMsg('tooltip-protect'),
392 'akey' => wfMsg('accesskey-protect')
393 );
394
395 } else {
396 $content_actions['unprotect'] = array(
397 'class' => ($action == 'unprotect') ? 'selected' : false,
398 'text' => wfMsg('unprotect'),
399 'href' => $this->makeUrl($this->thispage, 'action=unprotect'),
400 'ttip' => wfMsg('tooltip-protect'),
401 'akey' => wfMsg('accesskey-protect')
402 );
403 }
404 $content_actions['delete'] = array(
405 'class' => ($action == 'delete') ? 'selected' : false,
406 'text' => wfMsg('delete'),
407 'href' => $this->makeUrl($this->thispage, 'action=delete'),
408 'ttip' => wfMsg('tooltip-delete'),
409 'akey' => wfMsg('accesskey-delete')
410 );
411 }
412 if ( $wgUser->getID() != 0 ) {
413 if ( $wgTitle->userCanEdit()) {
414 $content_actions['move'] = array('class' => ($wgTitle->getDbKey() == 'Movepage' and $wgTitle->getNamespace == Namespace::getSpecial()) ? 'selected' : false,
415 'text' => wfMsg('move'),
416 'href' => $this->makeSpecialUrl('Movepage', 'target='.$this->thispage),
417 'ttip' => wfMsg('tooltip-move'),
418 'akey' => wfMsg('accesskey-move'));
419 } else {
420 $content_actions['move'] = array('class' => 'inactive',
421 'text' => wfMsg('move'),
422 'href' => false,
423 'ttip' => wfMsg('tooltip-nomove'),
424 'akey' => false);
425
426 }
427 }
428 } else {
429 //article doesn't exist or is deleted
430 if($wgUser->isSysop()){
431 if( $n = $wgTitle->isDeleted() ) {
432 $content_actions['delete'] = array(
433 'class' => false,
434 'text' => wfMsg( "undelete_short", $n ),
435 'href' => $this->makeSpecialUrl('Undelete/'.$this->thispage),
436 'ttip' => wfMsg('tooltip-undelete', $n),
437 'akey' => wfMsg('accesskey-undelete')
438 );
439 }
440 }
441 }
442
443 if ( $wgUser->getID() != 0 and $action != 'edit' and $action != 'submit' ) {
444 if( !$wgTitle->userIsWatching()) {
445 $content_actions['watch'] = array('class' => ($action == 'watch' or $action == 'unwatch') ? 'selected' : false,
446 'text' => wfMsg('watch'),
447 'href' => $this->makeUrl($this->thispage, 'action=watch'),
448 'ttip' => wfMsg('tooltip-watch'),
449 'akey' => wfMsg('accesskey-watch'));
450 } else {
451 $content_actions['watch'] = array('class' => ($action == 'unwatch' or $action == 'watch') ? 'selected' : false,
452 'text' => wfMsg('unwatch'),
453 'href' => $this->makeUrl($this->thispage, 'action=unwatch'),
454 'ttip' => wfMsg('tooltip-unwatch'),
455 'akey' => wfMsg('accesskey-unwatch'));
456
457 }
458 }
459 } else {
460 /* show special page tab */
461
462 $content_actions['article'] = array('class' => 'selected',
463 'text' => wfMsg('specialpage'),
464 'href' => false,
465 'ttip' => wfMsg('tooltip-specialpage'),
466 'akey' => false);
467 }
468
469 return $content_actions;
470 }
471
472 # build array of common navigation links
473 function buildNavUrls () {
474 global $wgTitle, $wgUser, $wgRequest;
475 global $wgSiteSupportPage;
476
477 $action = $wgRequest->getText( 'action' );
478 $oldid = $wgRequest->getVal( 'oldid' );
479 $diff = $wgRequest->getVal( 'diff' );
480 // XXX: remove htmlspecialchars when tal:attributes works with i18n:attributes
481 $nav_urls = array();
482 $nav_urls['mainpage'] = array('href' => htmlspecialchars( $this->makeI18nUrl('mainpage')));
483 $nav_urls['randompage'] = array('href' => htmlspecialchars( $this->makeSpecialUrl('Randompage')));
484 $nav_urls['recentchanges'] = array('href' => htmlspecialchars( $this->makeSpecialUrl('Recentchanges')));
485 $nav_urls['whatlinkshere'] = array('href' => htmlspecialchars( $this->makeSpecialUrl('Whatlinkshere', 'target='.$this->thispage)));
486 $nav_urls['currentevents'] = (wfMsg('currentevents') != '-') ? array('href' => htmlspecialchars( $this->makeI18nUrl('currentevents'))) : false;
487 $nav_urls['portal'] = (wfMsg('portal') != '-') ? array('href' => htmlspecialchars( $this->makeI18nUrl('portal-url'))) : false;
488 $nav_urls['recentchangeslinked'] = array('href' => htmlspecialchars( $this->makeSpecialUrl('Recentchangeslinked', 'target='.$this->thispage)));
489 $nav_urls['bugreports'] = array('href' => htmlspecialchars( $this->makeI18nUrl('bugreportspage')));
490 // $nav_urls['sitesupport'] = array('href' => htmlspecialchars( $this->makeI18nUrl('sitesupportpage')));
491 $nav_urls['sitesupport'] = array('href' => htmlspecialchars( $wgSiteSupportPage));
492 $nav_urls['help'] = array('href' => htmlspecialchars( $this->makeI18nUrl('helppage')));
493 $nav_urls['upload'] = array('href' => htmlspecialchars( $this->makeSpecialUrl('Upload')));
494 $nav_urls['specialpages'] = array('href' => htmlspecialchars( $this->makeSpecialUrl('Specialpages')));
495
496
497 $id=User::idFromName($wgTitle->getText());
498 $ip=User::isIP($wgTitle->getText());
499
500 if($id || $ip) { # both anons and non-anons have contri list
501 $nav_urls['contributions'] = array(
502 'href' => htmlspecialchars( $this->makeSpecialUrl('Contributions', "target=" . $wgTitle->getPartialURL() ) )
503 );
504 }
505 if ( 0 != $wgUser->getID() ) { # show only to signed in users
506 if($id) { # can only email non-anons
507 $nav_urls['emailuser'] = array(
508 'href' => htmlspecialchars( $this->makeSpecialUrl('Emailuser', "target=" . $wgTitle->getPartialURL() ) )
509 );
510 }
511 }
512
513
514 return $nav_urls;
515 }
516
517 function getNameSpaceWord () {
518 global $wgTitle;
519 switch ($wgTitle->getNamespace()) {
520 case NS_MAIN:
521 case NS_TALK:
522 return wfMsg('nstab-main');
523 case NS_USER:
524 case NS_USER_TALK:
525 return wfMsg('nstab-user');
526 case NS_MEDIA:
527 return wfMsg('nstab-media');
528 case NS_SPECIAL:
529 return wfMsg('nstab-special');
530 case NS_WP:
531 case NS_WP_TALK:
532 return wfMsg('nstab-wp');
533 case NS_IMAGE:
534 case NS_IMAGE_TALK:
535 return wfMsg('nstab-image');
536 case NS_MEDIAWIKI:
537 case NS_MEDIAWIKI_TALK:
538 return wfMsg('nstab-mediawiki');
539 case NS_TEMPLATE:
540 case NS_TEMPLATE_TALK:
541 return wfMsg('nstab-template');
542 case NS_HELP:
543 case NS_HELP_TALK:
544 return wfMsg('nstab-help');
545 case NS_CATEGORY:
546 case NS_CATEGORY_TALK:
547 return wfMsg('nstab-category');
548 default:
549 return wfMsg('nstab-main');
550 }
551 }
552
553 /* private */ function setupUserCssJs () {
554 global $wgRequest, $wgTitle;
555 $action = $wgRequest->getText('action');
556 if($wgTitle->isCssSubpage() and $action == 'submit' and $wgTitle->userCanEditCssJsSubpage()) {
557 // css preview
558 $this->usercss = $wgRequest->getText('wpTextbox1');
559 } else {
560 $this->usercss = '@import url('.
561 $this->makeUrl($this->userpage.'/'.$this->skinname.'.css', 'action=raw&ctype=text/css').');';
562 }
563 if($wgTitle->isJsSubpage() and $action == 'submit' and $wgTitle->userCanEditCssJsSubpage()) {
564 # XXX: additional security check/prompt?
565 $this->userjsprev = $wgRequest->getText('wpTextbox1');
566 } else {
567 $this->userjs = $this->makeUrl($this->userpage.'/'.$this->skinname.'.js', 'action=raw&ctype=text/javascript');
568 }
569 }
570
571 // Overload the Skin::newCardSet function to replace
572 // the default CardSet widget
573 function newCardSet( $title = "")
574 {
575 return new TabbedCardSet( $title );
576 }
577
578 }
579
580 class SkinDaVinci extends SkinPHPTal {
581 function initPage( &$out ) {
582 SkinPHPTal::initPage( $out );
583 $this->skinname = "davinci";
584 }
585 }
586
587 class SkinMono extends SkinPHPTal {
588 function initPage( &$out ) {
589 SkinPHPTal::initPage( $out );
590 $this->skinname = "mono";
591 }
592 }
593
594 class SkinMonoBook extends SkinPHPTal {
595 function initPage( &$out ) {
596 SkinPHPTal::initPage( $out );
597 $this->skinname = "monobook";
598 }
599 }
600
601 ?>